const app = getApp();
import * as constants from '../../../../common/Constants';
import * as umfDialog from '../../../../utils/UmfDialog';
import * as utils from '../../../../utils/UmfUtils';
import DeviceUtils from '../../../../utils/DeviceUtils';

Page({
    data: {
        userId: '',
        qrUrl: '',

        showShareGuide: false
    },

    onLoad: function (options) {
        this.setData({
            agentName: app.globalData.userData.agentName,
            userId: options.userId,
            qrUrl: decodeURIComponent(options.qrUrl)
        });
    },

    onSend: function () {
        let noShareTip = utils.getStorageSync(constants.Keys.NO_SHARE_TIP);
        if (!noShareTip ) {
            let message = DeviceUtils.isIos() ? "请长按图片，选择发送给好友" : "请点击微信右上角按钮后,选择发送给好友";

            umfDialog.showAll(message, "不再提示", "确定", ()=> {
                //预览图片
                wx.previewImage({
                    current: this.data.qrUrl,
                    urls: [this.data.qrUrl],
                });
            }, ()=> {
                utils.setStorageSync(constants.Keys.NO_SHARE_TIP, true);
                //预览图片
                wx.previewImage({
                    current: this.data.qrUrl,
                    urls: [this.data.qrUrl],
                });
            });
        } else {
            //预览图片
            wx.previewImage({
                current: this.data.qrUrl,
                urls: [this.data.qrUrl],
            });
        }
    }
});